<template>
  <div class="box">
    <div class="side front backgroundimg"></div>
    <div class="side back"></div>
    <div class="side left"></div>
    <div class="side right"></div>
    <div class="side top">
      <div class="tl"></div>
      <div class="tr"></div>
    </div>
    <div class="side bottom"></div>
    <div class="text">
      加油，努力，你最棒
      <img
        width="50"
        height="50"
        src="https://img2.baidu.com/it/u=3120170833,355021607&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500"
        alt=""
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'OpenExpress'
}
</script>

<style scoped>
.box {
  display: flex;
  justify-content: center;
  align-items: center;
  /* 相对定位 */
  position: relative;
  /* 开启3D效果 */
  transform-style: preserve-3d;
  /* 设置视距 */
  perspective: 1000px;
  /* 默认沿X轴旋转-20度 */
  transform: rotateX(-20deg);
}
.backgroundimg {
  background: url('https://img.thgykj.com/thgy-file/671a6fbb31174a2b82c0e2bedcde0b8b1708918393153.svg')
    no-repeat center center;
  background-size: 50% 50%;
}
/* 箱子各个面的统一样式 */
.side {
  /* 绝对定位 */
  position: absolute;
  width: 200px;
  height: 200px;
  background-color: #c09551;
  border: 1px solid #e4c084;
}
/* 前 */
.front {
  transform: translateZ(100px);
}
/* 后 */
.back {
  transform: translateZ(-100px) rotateY(180deg);
}
/* 左 */
.left {
  transform: translateX(-100px) rotateY(-90deg);
}
/* 右 */
.right {
  transform: translateX(100px) rotateY(90deg);
}
/* 上 */
.top {
  transform: translateY(-100px) rotateX(90deg);
  background-color: transparent;
  transform-style: preserve-3d;
}
.top div {
  background-color: #c09551;
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  border: 1px solid #e4c084;
  /* 设置过渡 */
  transition: 0.5s;
}
.top .tl {
  left: 0;
  /* 设置旋转的基点位置为左边 */
  transform-origin: left;
}
.top .tr {
  right: 0;
  /* 设置旋转的基点位置为右边 */
  transform-origin: right;
}
/* 下 */
.bottom {
  transform: translateY(100px) rotateX(-90deg);
  /* 阴影 */
  box-shadow: 5px -5px 15px rgba(0, 0, 0, 0.4);
}
.box:hover .top .tl {
  transform: rotateY(-135deg);
}
.box:hover .top .tr {
  transform: rotateY(135deg);
}
.box .text {
  width: 200px;
  text-align: center;
  font-size: 30px;
  font-weight: bold;
  transition: 0.6s;
  z-index: 999;
}
.box:hover .text {
  transform: translateY(-250px);
}
</style>
